/*

#include <databaselib/io/mysql.h>
#include <utillib/util/util.h>
#include <databaselib/io/DBCommon.h>

using namespace databaselib::io;

MySQL::MySQL( AgentMYSQL *parentDB ) : m_parentDB( parent ), m_resultSet( NULL ), m_columnNo( 0 ) 
{
}

MySQL::~MySQL()
{
	close();
}

bool MySQL::connect()
{
	mysql_init( &m_connection );
	m_isConnect = false;
	if ( mysql_real_connect( &m_connection, m_parentDB->getIP(), m_parentDB->getID(), m_parentDB->getPassword(), 
				m_parentDB->getCatalog(), 0, (char *)NULL, 0 ) )
	{
		if ( !mysql_select_db( &m_connection, dbname ) ) m_isConnect = true;
	}
	return ( m_isConnect );
}

void MySQL::close()
{
	if ( isConnect() )
	{
		endFetch();
		mysql_close( &m_connection );
	}
	m_isConnect = false;
}

bool MySQL::executeSQL(const char *query )
{
	endFetch();
	m_maxColumn = 0;
	m_rowset = NULL;
	
	if ( mysql_real_query( &m_connection, query, strlen( query ) ) )
	{
		m_isConnect = false;
		return ( false );
	}
	m_resultSet = mysql_store_result( &m_connection );
	
	if ( m_resultSet )
	{
		m_maxColumn = mysql_field_count( &m_connection );
		return ( true );
	}

	if ( !mysql_errno( &m_connection ) )
	{
		if ( mysql_field_count( &m_connection ) == 0 ) return ( true );
	}
#ifdef _DEBUG
	printf( "Query Execute Error :'%s'\r\n", query );
#endif
	WriteLog::getInstance()->put( query );
	return ( false );
}

bool MySQL::fetch()
{
	if ( !m_resultSet ) return ( false );

	m_rowset = mysql_fetch_row( m_resultSet );
	if ( !m_rowset ) return ( false );
	m_columnNo = 0;

	return ( true );
}

bool MySQL::endFetch()
{
	if ( m_resultSet ) mysql_free_result( m_resultSet );
	m_resultSet = NULL;
	return ( true );
}

char *MySQL::getNextData()
{
	if ( m_columnNo >= m_maxColumn ) return ( NULL );
	if ( !m_rowset ) return ( NULL );

	char *data = m_rowset[ m_columnNo ];
	m_columnNo++;
	return ( data );
}

MySQL& MySQL::operator >> ( float &out )
{
	char *data = getNextData();
	if ( data ) out = atof( data );

	return ( *this );
}

MySQL& MySQL::operator >> ( char *out )
{
	char *data = getNextData();
	if ( data ) strcpy_s( out , MAX_DB_STRING_SIZE, data );

	return ( *this );
}

MySQL& MySQL::operator >> ( struct tm &out )
{
	char *data = getNextData();
	if ( data ) strToTimeStamp( data, &out );
	return ( *this );
}

MySQL& MySQL::operator >> ( SmallDate &out )
{
	char *data = getNextData();
	if ( data ) strToSmallDate( data, &out );
	return ( *this );
}

bool MySQL::strToTimeStamp( const char *str,struct tm *tm )
{
	ZeroMemory( tm, sizeof( struct tm ) );
	int length = strlen( str );
	int position = 0;

	if ( length != 19 ) return ( false );

	tm->tm_year = cpp::lang::strToInt( &str[ position ], 4 );
	position += 5;
	tm->tm_mon = cpp::lang::strToInt( &str[ position ], 2 );
	position += 3;
	tm->tm_mday = cpp::lang::strToInt( &str[ position ], 2 );

	position += 3;
	tm->tm_hour = cpp::lang::strToInt( &str[ position ], 2 );
	position += 3;
	tm->tm_min = cpp::lang::strToInt( &str[ position ], 2 );
	position += 3;
	tm->tm_sec = cpp::lang::strToInt( &str[ position ], 2 );

	return ( true );
}

bool MySQL::strToSmallDate( const char *str,SmallDate *smallDate )
{
	ZeroMemory( smallDate, sizeof( SmallDate ) );
	int length = strlen( str );
	int position = 0;

	if ( length != 19 ) return ( false );

	smallDate->year = cpp::lang::strToInt( &str[ position ], 4 );
	position += 5;
	smallDate->mon = cpp::lang::strToInt( &str[ position ], 2 );
	position += 3;
	smallDate->day = cpp::lang::strToInt( &str[ position ], 2 );

	return ( true );
}

AgentMYSQL::AgentMYSQL() 
{
}

AgentMYSQL::~AgentMYSQL()
{
}


bool AgentMYSQL::initializeDataBaseEnv( char *serverAddress, char *catalog, char *userid, char *password )
{
	if ( ( serverAddress == NULL ) || ( catalog == NULL ) || ( userid == NULL ) || ( password == NULL ) ) return ( false );

	COPY_STRING( m_serverAddress, serverAddress );
	COPY_STRING( m_userid, userid );
	COPY_STRING( m_password, password );
	COPY_STRING( m_catalog, catalog );

	return ( true );
}


bool AgentMYSQL::releaseDataBaseEnv()
{
	SAFE_DELETE_ARRAY( m_serverAddress );
	SAFE_DELETE_ARRAY( m_userid );
	SAFE_DELETE_ARRAY( m_password );
	SAFE_DELETE_ARRAY( m_catalog );

	return ( true );
}

MySQL* AgentMYSQL::getNewDBInstance()
{
	MySQL *dataBase = new MySQL( this );

	dataBase->connect( m_serverAddress, m_userid, m_password, m_catalog );
	return ( dataBase );

}

*/